* ============================================================================ *
* PROJECT:		Is Incumbency Advantage Gendered?
* AUTHOR: 		Semra Sevi 
* DATE:			2022-01-25
* ============================================================================ *

**********************
****** Appendix ******
**********************

*A1: Main models 

*** All candidates 

* Runs again as DV	
rdrobust runs_again margin_victory if year >= 1960, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all

rdrobust runs_again margin_victory if year >= 1970, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
rdrobust runs_again margin_victory if year >= 1980, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all
	
rdrobust runs_again margin_victory if year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all

* Elected as DV	
rdrobust elected_next margin_victory if year >= 1960, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 

rdrobust elected_next margin_victory if year >= 1970, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 	
	
rdrobust elected_next margin_victory if year >= 1980, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 
	
rdrobust elected_next margin_victory if year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 
	
* Result next as DV
	
rdrobust percent_votes_next margin_victory if year >= 1960, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 
	
rdrobust percent_votes_next margin_victory if year >= 1970, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 	
	
rdrobust percent_votes_next margin_victory if year >= 1980, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 
	
rdrobust percent_votes_next margin_victory if year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 
	
*** Gender Analysis 

* Men 

* Runs again as DV	
rdrobust runs_again margin_victory if gender == 0 & year >= 1960,  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
rdrobust runs_again margin_victory if gender == 0 & year >= 1970,  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
rdrobust runs_again margin_victory if gender == 0 & year >= 1980,  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
rdrobust runs_again margin_victory if gender == 0 & year >= 1990,  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	

* Women 

* Runs again as DV	
rdrobust runs_again margin_victory if gender == 1 & year >= 1960,  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
rdrobust runs_again margin_victory if gender == 1 & year >= 1970,  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
rdrobust runs_again margin_victory if gender == 1 & year >= 1980,  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
rdrobust runs_again margin_victory if gender == 1 & year >= 1990,  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all		
	
* Men 
	
* Elected as DV		
rdrobust elected_next margin_victory if gender == 0 & year >= 1960, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 
	
rdrobust elected_next margin_victory if gender == 0 & year >= 1970, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust elected_next margin_victory if gender == 0 & year >= 1980, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust elected_next margin_victory if gender == 0 & year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all

* Women 

* Elected as DV
rdrobust elected_next margin_victory if gender == 1 & year >= 1960, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all

rdrobust elected_next margin_victory if gender == 1 & year >= 1970, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all
	
rdrobust elected_next margin_victory if gender == 1 & year >= 1980, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all
	
rdrobust elected_next margin_victory if gender == 1 & year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
		
* Men 

* Result next as DV
rdrobust percent_votes_next margin_victory if gender == 0 & year >= 1960, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	

rdrobust percent_votes_next margin_victory if gender == 0 & year >= 1970, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	

rdrobust percent_votes_next margin_victory if gender == 0 & year >= 1980, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
rdrobust percent_votes_next margin_victory if gender == 0 & year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
* Women 

* Result next as DV	
rdrobust percent_votes_next margin_victory if gender == 1 & year >= 1960, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all
	
rdrobust percent_votes_next margin_victory if gender == 1 & year >= 1970, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all
	
rdrobust percent_votes_next margin_victory if gender == 1 & year >= 1980, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all
	
rdrobust percent_votes_next margin_victory if gender == 1 & year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all


	
* A2: Imbalance checks 	

* Everyone 

*Number of Women 
rdrobust num_women margin_victory if year >= 1990, all

*Number of Candidates	
rdrobust num_candidates margin_victory if year >= 1990, all

*Electoral Experience 
rdrobust electoral_exp margin_victory if year >= 1990, all
		
** Women 

*Number of Candidates	
rdrobust num_candidates margin_victory if year >= 1990 & gender == 1, all
		
*Electoral Experience
rdrobust electoral_exp margin_victory if year >= 1990 & gender == 1, all
	
* Men 

*Number of Candidates
rdrobust num_candidates margin_victory if year >= 1990 & gender == 0, all	

*Electoral Experience
rdrobust electoral_exp margin_victory if year >= 1990 & gender == 0, all	
	
	
* A3: Density checks 
*net install lpdensity, from(https://sites.google.com/site/nppackages/lpdensity/stata) replace
	
rddensity margin_victory if year >= 1990, plot graph_opt( title("All Candidates") ///
	xtitle("Margin of victory at t") ytitle("Density")legend(off)xline(0)) ///
	esll_opt(color(grey%30)) cirl_opt(color(grey%30)) ///
	eslr_opt(color(black)) cirr_opt(color(black%70)) nohistogram 

rddensity margin_victory if year >= 1990 & gender ==0, plot graph_opt( title("Men Only") ///
	xtitle("Margin of victory at t") ytitle("Density")legend(off)xline(0)) ///
	esll_opt(color(grey%30)) cirl_opt(color(grey%30)) ///
	eslr_opt(color(black)) cirr_opt(color(black%70)) nohistogram 
	
rddensity margin_victory if year >= 1990 & gender ==1, plot graph_opt( title("Women Only") ///
	xtitle("Margin of victory at t") ytitle("Density")legend(off)xline(0)) ///
	esll_opt(color(grey%30)) cirl_opt(color(grey%30)) ///
	eslr_opt(color(black)) cirr_opt(color(black%70)) nohistogram 
	
	
graph combine "d_all.gph" "d_men.gph" "d_women.gph", row(1) xsize(14) xcommon ycommon scheme(s1mono) 
	
	
* A4: T-tests 

*Men

* Runs again as DV
rdrobust runs_again margin_victory if gender == 0 & year >= 1990,  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	

* Lower bound estimates 
scalar n_l_m = e(N_h_l)
scalar b_l_m = e(tau_cl_l)
matrix _V = e(V_cl_l)
scalar sd_l_m = sqrt(_V[1, 1])

* Higher bound estimates 
scalar n_r_m = e(N_h_r)
scalar b_r_m = e(tau_cl_r)
matrix _V = e(V_cl_r)
scalar sd_r_m = sqrt(_V[1, 1])	
	
	
* Women

* Runs again as DV
rdrobust runs_again margin_victory if gender == 1 & year >= 1990,  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all		
	
* Lower bound estimates 
scalar n_l_w = e(N_h_l)
scalar b_l_w = e(tau_cl_l)
matrix _V = e(V_cl_l)
scalar sd_l_w = sqrt(_V[1, 1])

* Higher bound estimates 
scalar n_r_w = e(N_h_r)
scalar b_r_w = e(tau_cl_r)
matrix _V = e(V_cl_r)
scalar sd_r_w = sqrt(_V[1, 1])	
	
* Compare upper bounds for subsamples 
ttesti `=n_r_m' `=b_r_m' `=sd_r_m' `=n_r_w' `=b_r_w' `=sd_r_w', unequal  
	
* Compare lower bounds for subsamples 
ttesti `=n_l_m' `=b_l_m' `=sd_l_m' `=n_l_w' `=b_l_w' `=sd_l_w', unequal  	
	
	
* Men	
	
* Elected as DV conditional on rerunning 
rdrobust elected_next margin_victory if gender == 0 & year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
* Lower bound estimates 
scalar n_l_m = e(N_h_l)
scalar b_l_m = e(tau_cl_l)
matrix _V = e(V_cl_l)
scalar sd_l_m = sqrt(_V[1, 1])

* Higher bound estimates 
scalar n_r_m = e(N_h_r)
scalar b_r_m = e(tau_cl_r)
matrix _V = e(V_cl_r)
scalar sd_r_m = sqrt(_V[1, 1])
	
	
* Women
		
* Elected as DV conditional on rerunning 
rdrobust elected_next margin_victory if gender == 1 & year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all		
	
* Lower bound estimates 
scalar n_l_w = e(N_h_l)
scalar b_l_w = e(tau_cl_l)
matrix _V = e(V_cl_l)
scalar sd_l_w = sqrt(_V[1, 1])

* Higher bound estimates 
scalar n_r_w = e(N_h_r)
scalar b_r_w = e(tau_cl_r)
matrix _V = e(V_cl_r)
scalar sd_r_w = sqrt(_V[1, 1])	

* Compare upper bounds for subsamples 
ttesti `=n_r_m' `=b_r_m' `=sd_r_m' `=n_r_w' `=b_r_w' `=sd_r_w', unequal  
	
* Compare lower bounds for subsamples 
ttesti `=n_l_m' `=b_l_m' `=sd_l_m' `=n_l_w' `=b_l_w' `=sd_l_w', unequal  
	
	
* Men	
	
* Result next as DV conditional on rerunning 
rdrobust percent_votes_next margin_victory if gender == 0 & year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
* Lower bound estimates 
scalar n_l_m = e(N_h_l)
scalar b_l_m = e(tau_cl_l)
matrix _V = e(V_cl_l)
scalar sd_l_m = sqrt(_V[1, 1])

* Higher bound estimates 
scalar n_r_m = e(N_h_r)
scalar b_r_m = e(tau_cl_r)
matrix _V = e(V_cl_r)
scalar sd_r_m = sqrt(_V[1, 1])	
	

* Women

* Result next as DV conditional on rerunning 
rdrobust percent_votes_next margin_victory if gender == 1 & year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all

* Lower bound estimates 
scalar n_l_w = e(N_h_l)
scalar b_l_w = e(tau_cl_l)
matrix _V = e(V_cl_l)
scalar sd_l_w = sqrt(_V[1, 1])

* Higher bound estimates 
scalar n_r_w = e(N_h_r)
scalar b_r_w = e(tau_cl_r)
matrix _V = e(V_cl_r)
scalar sd_r_w = sqrt(_V[1, 1])		
	

* Compare upper bounds for subsamples 
ttesti `=n_r_m' `=b_r_m' `=sd_r_m' `=n_r_w' `=b_r_w' `=sd_r_w', unequal  
	
* Compare lower bounds for subsamples 
ttesti `=n_l_m' `=b_l_m' `=sd_l_m' `=n_l_w' `=b_l_w' `=sd_l_w', unequal  	
		
	
* A5: Runs again anytime 	
	
* All Candidates 
	
* Runs again as DV 
rdrobust runs_again_anytime margin_victory if year >= 1990, ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
*Male Gender regression 

* Runs again sometime in the future as DV
rdrobust runs_again_anytime margin_victory if gender == 0 & year >= 1990,  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	

* Female Gender regression 

* Runs again sometime in the future as DV
rdrobust runs_again_anytime margin_victory if gender == 1 & year >= 1990, covs(major_party d_year*)  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
* RDMC 	
*Runs again as DV
rdmc runs_again_anytime artificial_margin if year >= 1990,  ///
	cvar(artificial_cutoff) pvar(pv) kernelvar(kv) bwselectvar(bwsv) vcevar(vcev) ///
	pooled_opt(p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster year))
	*pooled_opt(covs(major_party d_year*)
lincom c1-c2 	
display r(estimate)/r(se)	
	
	
	
* A6: % of incumbents in each election 

preserve
collapse (mean) incumbent if type_elxn == 1 & year >= 1921, by(year) 
gen incumbent_ = incumbent*100
twoway line incumbent_ year, lwidth(medthick) xlabel(1921(20)2021) ytitle("Percent of incumbents") ///
	xtitle("Year") title("") saving("incumbent_candidates.gph", replace)
restore	 	
	
	
* A7: Models with party*year fixed effects

*** All candidates 

* Runs again as DV	
rdrobust runs_again margin_victory if year >= 1960, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all
	
rdrobust runs_again margin_victory if year >= 1970, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all
	
rdrobust runs_again margin_victory if year >= 1980, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	

rdrobust runs_again margin_victory if year >= 1990, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all
	
* Elected as DV
rdrobust elected_next margin_victory if year >= 1960, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
rdrobust elected_next margin_victory if year >= 1970, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
rdrobust elected_next margin_victory if year >= 1980, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
rdrobust elected_next margin_victory if year >= 1990, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
* Result next as DV
rdrobust percent_votes_next margin_victory if year >= 1960, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 
	
rdrobust percent_votes_next margin_victory if year >= 1970, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 
	
rdrobust percent_votes_next margin_victory if year >= 1980, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 
	
rdrobust percent_votes_next margin_victory if year >= 1990, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all 
	
*** Gender Analysis 

* Men 

* Runs again as DV	
rdrobust runs_again margin_victory if gender == 0 & year >= 1960, covs(party_year_fe)  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	

rdrobust runs_again margin_victory if gender == 0 & year >= 1970, covs(party_year_fe)  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
rdrobust runs_again margin_victory if gender == 0 & year >= 1980, covs(party_year_fe)  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
rdrobust runs_again margin_victory if gender == 0 & year >= 1990, covs(party_year_fe)  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
* Women 

* Runs again as DV	
rdrobust runs_again margin_victory if gender == 1 & year >= 1960, covs(party_year_fe)  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	

rdrobust runs_again margin_victory if gender == 1 & year >= 1970, covs(party_year_fe)  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	

rdrobust runs_again margin_victory if gender == 1 & year >= 1980, covs(party_year_fe)  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	
	
rdrobust runs_again margin_victory if gender == 1 & year >= 1990, covs(party_year_fe)  ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all	

* Men 
	
* Elected as DV		
rdrobust elected_next margin_victory if gender == 0 & year >= 1960, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all

rdrobust elected_next margin_victory if gender == 0 & year >= 1970, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust elected_next margin_victory if gender == 0 & year >= 1980, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust elected_next margin_victory if gender == 0 & year >= 1990, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all
	
* Women 

* Elected as DV
rdrobust elected_next margin_victory if gender == 1 & year >= 1960, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
rdrobust elected_next margin_victory if gender == 1 & year >= 1970, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	

rdrobust elected_next margin_victory if gender == 1 & year >= 1980, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
rdrobust elected_next margin_victory if gender == 1 & year >= 1990, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
* Men 

* Result next as DV
rdrobust percent_votes_next margin_victory if gender == 0 & year >= 1960, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all

rdrobust percent_votes_next margin_victory if gender == 0 & year >= 1970, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust percent_votes_next margin_victory if gender == 0 & year >= 1980, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust percent_votes_next margin_victory if gender == 0 & year >= 1990, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num)	all
	
* Women 

* Result next as DV
rdrobust percent_votes_next margin_victory if gender == 1 & year >= 1960, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
rdrobust percent_votes_next margin_victory if gender == 1 & year >= 1970, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
rdrobust percent_votes_next margin_victory if gender == 1 & year >= 1980, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	
	
rdrobust percent_votes_next margin_victory if gender == 1 & year >= 1990, covs(party_year_fe) ///
	p(1) kernel(triangular) bwselect(mserd) ///
	vce(nncluster prov_riding_num) all	


*A8: Results according to different bandwidth size post 1990

*Everyone - Rerunning 
rdrobust runs_again margin_victory if year >= 1990, ///
	p(1) kernel(triangular) h(15) ///
	vce(nncluster prov_riding_num)	all

rdrobust runs_again margin_victory if year >= 1990, ///
	p(1) kernel(triangular) h(10) ///
	vce(nncluster prov_riding_num) all
	
rdrobust runs_again margin_victory if year >= 1990, ///
	p(1) kernel(triangular) h(5) ///
	vce(nncluster prov_riding_num) all
	
	
*Everyone - Elected conditional on rerunning
rdrobust elected_next margin_victory if year >= 1990, ///
	p(1) kernel(triangular) h(15) ///
	vce(nncluster prov_riding_num) all
	
rdrobust elected_next margin_victory if year >= 1990, ///
	p(1) kernel(triangular) h(10) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust elected_next margin_victory if year >= 1990, ///
	p(1) kernel(triangular) h(5) ///
	vce(nncluster prov_riding_num)	all	
	
*Everyone - Vote Share 
rdrobust percent_votes_next margin_victory if year >= 1990, ///
	p(1) kernel(triangular) h(15) ///
	vce(nncluster prov_riding_num)	all	
	
rdrobust percent_votes_next margin_victory if year >= 1990, ///
	p(1) kernel(triangular) h(10) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust percent_votes_next margin_victory if year >= 1990, ///
	p(1) kernel(triangular) h(5) ///
	vce(nncluster prov_riding_num) all
	
	
*Men - Rerunning 
rdrobust runs_again margin_victory if year >= 1990 & gender == 0, ///
	p(1) kernel(triangular) h(15) ///
	vce(nncluster prov_riding_num)	all

rdrobust runs_again margin_victory if year >= 1990 & gender == 0, ///
	p(1) kernel(triangular) h(10) ///
	vce(nncluster prov_riding_num) all
	
rdrobust runs_again margin_victory if year >= 1990 & gender == 0, ///
	p(1) kernel(triangular) h(5) ///
	vce(nncluster prov_riding_num)	all
		

*Men - Elected conditional on rerunning
rdrobust elected_next margin_victory if year >= 1990 & gender == 0, ///
	p(1) kernel(triangular) h(15) ///
	vce(nncluster prov_riding_num)	all

rdrobust elected_next margin_victory if year >= 1990 & gender == 0, ///
	p(1) kernel(triangular) h(10) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust elected_next margin_victory if year >= 1990 & gender == 0, ///
	p(1) kernel(triangular) h(5) ///
	vce(nncluster prov_riding_num)	all	

*Men - Vote Share 
rdrobust percent_votes_next margin_victory if year >= 1990 & gender == 0, ///
	p(1) kernel(triangular) h(15) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust percent_votes_next margin_victory if year >= 1990 & gender == 0, ///
	p(1) kernel(triangular) h(10) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust percent_votes_next margin_victory if year >= 1990 & gender == 0, ///
	p(1) kernel(triangular) h(5) ///
	vce(nncluster prov_riding_num)	all
	
	
*Women - Rerunning 
rdrobust runs_again margin_victory if year >= 1990 & gender == 1, ///
	p(1) kernel(triangular) h(15) ///
	vce(nncluster prov_riding_num)	all

rdrobust runs_again margin_victory if year >= 1990 & gender == 1, ///
	p(1) kernel(triangular) h(10) ///
	vce(nncluster prov_riding_num) all
	
rdrobust runs_again margin_victory if year >= 1990 & gender == 1, ///
	p(1) kernel(triangular) h(5) ///
	vce(nncluster prov_riding_num)	all		


*Women - Elected conditional on rerunning
rdrobust elected_next margin_victory if year >= 1990 & gender == 1, ///
	p(1) kernel(triangular) h(15) ///
	vce(nncluster prov_riding_num)	all	
	
rdrobust elected_next margin_victory if year >= 1990 & gender == 1, ///
	p(1) kernel(triangular) h(10) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust elected_next margin_victory if year >= 1990 & gender == 1, ///
	p(1) kernel(triangular) h(5) ///
	vce(nncluster prov_riding_num)	all
	
*Women - Vote Share 
rdrobust percent_votes_next margin_victory if year >= 1990 & gender == 1, ///
	p(1) kernel(triangular) h(15) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust percent_votes_next margin_victory if year >= 1990 & gender == 1, ///
	p(1) kernel(triangular) h(10) ///
	vce(nncluster prov_riding_num)	all
	
rdrobust percent_votes_next margin_victory if year >= 1990 & gender == 1, ///
	p(1) kernel(triangular) h(5) ///
	vce(nncluster prov_riding_num)	all	


	
* A9: Alternative Model Specification (OLS)

gen elected_f = (gender==1) * (margin_victory >= 0) if !missing(margin_victory)
gen elected_m = (gender==0) * (margin_victory >= 0) if !missing(margin_victory)
gen margin_f = (gender==1) * margin_victory 
gen margin_m = (gender==0) * margin_victory

* Runs again 

eststo clear 

eststo: reg runs_again ib0.gender elected_f elected_m margin_f margin_m  ///
	i.party_year_fe if year >= 1960 & abs(margin_victory) < 11, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p)
estadd local hasyear "Yes" 

eststo: reg runs_again ib0.gender elected_f elected_m margin_f margin_m  ///
	i.party_year_fe if year >= 1970 & abs(margin_victory) < 13, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p) 
estadd local hasyear "Yes" 

eststo: reg runs_again ib0.gender elected_f elected_m margin_f margin_m  ///
	i.party_year_fe if year >= 1980 & abs(margin_victory) < 13, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p) 
estadd local hasyear "Yes" 

eststo: reg runs_again ib0.gender elected_f elected_m margin_f margin_m  ///
	i.party_year_fe if year >= 1990 & abs(margin_victory) < 14, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p) 
estadd local hasyear "Yes" 

ereturn list 

* Saves table in a rich text file 
esttab using "runs_again.rtf",   ///
		label replace nogap nobaselevels compress b(3) se(3) 	///
		mtitles("1960" "1970" "1980" "1990") drop(*party_year_fe*) ///
		scalars("hasyear Party-by-Year Fixed Effects" "balancef F-stat" "balancep p" "N N" "r2 R2" "r2_a R2 Adj.") 		
		

* Elected 		
		
eststo clear		
eststo: reg elected_next ib0.gender elected_f elected_m margin_f margin_m   ///
	i.party_year_fe if year >= 1960 & abs(margin_victory) < 13, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p) 
estadd local hasyear "Yes" 

eststo: reg elected_next ib0.gender elected_f elected_m margin_f margin_m  ///
	i.party_year_fe if year >= 1970 & abs(margin_victory) < 14, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p) 
estadd local hasyear "Yes" 

eststo: reg elected_next ib0.gender elected_f elected_m margin_f margin_m  ///
	i.party_year_fe if year >= 1980 & abs(margin_victory) < 16, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p) 
estadd local hasyear "Yes" 

eststo: reg elected_next ib0.gender elected_f elected_m margin_f margin_m   ///
	i.party_year_fe if year >= 1990 & abs(margin_victory) < 17, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p) 
estadd local hasyear "Yes" 

* Saves table in a rich text file 
esttab using "elected.rtf",   ///
		label replace nogap nobaselevels compress b(3) se(3) 	///
		mtitles("1960" "1970" "1980" "1990") drop(*party_year_fe*) ///
		scalars("hasyear Party-by-Year Fixed Effects" "balancef F-stat" "balancep p" "N N" "r2 R2" "r2_a R2 Adj.") 			

* Vote share 

eststo clear		
eststo: reg percent_votes_next ib0.gender elected_f elected_m margin_f margin_m   ///
	i.party_year_fe if year >= 1960 & abs(margin_victory) < 13, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p) 
estadd local hasyear "Yes"

eststo: reg percent_votes_next ib0.gender elected_f elected_m margin_f margin_m   ///
	i.party_year_fe if year >= 1970 & abs(margin_victory) < 13, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p) 
estadd local hasyear "Yes"

eststo: reg percent_votes_next ib0.gender elected_f elected_m margin_f margin_m  ///
	i.party_year_fe if year >= 1980 & abs(margin_victory) < 15, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p) 
estadd local hasyear "Yes"

eststo: reg percent_votes_next ib0.gender elected_f elected_m margin_f margin_m  ///
	i.party_year_fe if year >= 1990 & abs(margin_victory) < 12, cluster(prov_riding_num)
test elected_f = elected_m
estadd scalar balancef = r(F) 
estadd scalar balancep = r(p) 
estadd local hasyear "Yes"

* Saves table in a rich text file 
esttab using "percent_votes_next.rtf",   ///
		label replace nogap nobaselevels compress b(3) se(3) 	///
		mtitles("1960" "1970" "1980" "1990") drop(*party_year_fe*) ///
		scalars("hasyear Party-by-Year Fixed Effects" "balancef F-stat" "balancep p" "N N" "r2 R2" "r2_a R2 Adj.") 			
		
		
* A10: OLS Analyses with all observations 	
recode gender 2=.

eststo clear
eststo: reg runs_again ib0.gender##elected percent_votes if year >= 1990, cluster(prov_riding_num)

eststo: reg runs_again ib0.gender##elected i.prov_riding_party i.year ///
	if year >= 1990

eststo: reg elected_next ib0.gender##elected percent_votes if year >= 1990, cluster(prov_riding_num)
	
eststo: reg elected_next ib0.gender##elected i.prov_riding_party i.year ///
	if year >= 1990
	
eststo: reg percent_votes_next ib0.gender##elected percent_votes if year >= 1990, cluster(prov_riding_num)
	
eststo: reg percent_votes_next ib0.gender##elected i.prov_riding_party i.year ///
	if year >= 1990

* Saves table in a rich text file 
esttab using "ols_alt.rtf",   ///
		label replace nogap nobaselevels compress b(3) se(3) 	///
		mtitles("runs again" "runs again" "elected" "elected" "vote share" "vote share") drop(*prov_riding_party* *year*) ///
		scalars("N N" "r2 R2" "r2_a R2 Adj.") 			
	
